package com.gokzzz.config;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gokzzz.entity.SysQuartzJob;
import com.gokzzz.quartz.QuartzManage;
import com.gokzzz.service.ISysQuartzJobService;
import com.gokzzz.service.impl.SysQuartzJobServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author gokzzz
 * @date 2022-04-23 18:00
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class JobRunner implements ApplicationRunner {
    private final ISysQuartzJobService sysQuartzJobService;
    private final QuartzManage quartzManage;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<SysQuartzJob> list = sysQuartzJobService.list();
        list.forEach(quartzManage::createScheduler);
        log.info(">> 初始化定时任务成功 <<");
    }
}
